﻿using System;

namespace _07_Bridge
{
    /// <summary>
    /// 桥接模式
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Color c = new Red();
            PaintBrush thinBrush = new ThinBrush(c);  //颜色通过构造函数传入
            thinBrush.Draw();
            Console.WriteLine();
        }
    }
    //抽象类，涂颜色
    abstract class Color
    {
        public abstract void Colour();
    }
    //红色类，涂颜色的实现
    class Red : Color
    {
        public override void Colour()
        {
            Console.WriteLine("Red color....");
        }
    }
    //抽象类，画画
    abstract class PaintBrush
    {
        protected Color color;
        public PaintBrush(Color c)
        {
            color = c;
        }
        public abstract void Draw();
    }
    //中等笔刷画画的实现
    class MediumBrush:PaintBrush
    {
        public MediumBrush(Color c):base(c)
        {

        }
        public override void Draw()
        {
            Console.WriteLine("Medium line");
            color.Colour();
        }
    }
    //细笔刷画画的实现
    class ThinBrush : PaintBrush
    {
        public ThinBrush(Color c) : base(c)
        {

        }
        public override void Draw()
        {
            Console.WriteLine("Thin line");
            color.Colour();
        }
    }
}
